function ev_emve_timeseries_plots()

varstr = 'ev';
ystr = 'Excess Asset Value';

load('..\pseudo data\matlab_datatable_pseudo.mat', 'datatbl_pseudo')
datatbl = datatbl_pseudo;

allyears = unique(datatbl.fyear(isfinite(datatbl.fyear)));
datevec = datetime(allyears, 12, 1);

close all
figure
set(gcf, 'Position', [50 90 1500 800]*0.6)
set(gcf, 'Color', 'w');

stattbl = grpstats(datatbl, 'fyear', {@(x)prctile(x, 75), @(x)prctile(x, 50), @(x)prctile(x, 25), @(x)mean(x, 'omitmissing')}, 'DataVars', varstr);

lowerline = stattbl.(['Fun1_' varstr]);
upperline = stattbl.(['Fun3_' varstr]);
medianline = stattbl.(['Fun2_' varstr]);
meanline = stattbl.(['Fun4_' varstr]);

id2rm = isnan(medianline);
lowerline(id2rm) = [];
upperline(id2rm) = [];
medianline(id2rm) = [];
meanline(id2rm) = [];
allyears(id2rm) = [];
datevec(id2rm) = [];

x_plot =[datevec; flipud(datevec)];
y_plot=[lowerline; flipud(upperline)];
hold on
p(1) = fill(x_plot, y_plot, 'blue', 'Edgecolor', 'none', 'FaceAlpha', 0.2, 'LineStyle','none');
p(2) = plot(datevec, medianline, 'LineWidth', 1.5, 'Color', 'blue');
plot(datevec, zeros(size(datevec)), 'LineStyle','-.', 'Color',[0.5 0.5 0.5])
hold off

grid minor
ylabel(ystr,'Interpreter','latex')
xlabel('Year','Interpreter','latex')
box off
axis tight
legend([p(1), p(2)], {'25-75 Percentile', 'Median'}, 'Location', 'southwest', 'FontSize', 10, 'Interpreter','latex')
legend boxoff

end


